package com.jt.www.domain.enums.pc;

import org.apache.commons.lang3.StringUtils;

/**
 * 渠道编码
 *
 * @author lq
 * @create 2020-04-07 15:18
 */
public enum MarketerChannelCodeEnum {
    TOUR_A01("文旅", "A01", "tour"),
    EDU_A02("教育", "A02", "edu"),
    MED_A03("卫生", "A03", "med"),
    FINANCE_A04("金融", "A04", "finance"),
    SEQUIP_A05("特设", "A05", "sequip"),
    OTHER("其他", "", "");

    private String msg;
    /**
     * 私保的channelCode
     */
    private String code;
    /**
     * 大平台的新的channelCode
     */
    private String newCode;

    MarketerChannelCodeEnum(String msg, String code, String newCode) {
        this.msg = msg;
        this.code = code;
        this.newCode = newCode;
    }

    /**
     * 通过单个code 得到描述
     *
     * @param code
     * @return
     */
    public static String getMsgByCode(String code) {
        for (MarketerChannelCodeEnum agreeStatusEnum : MarketerChannelCodeEnum.values()) {
            if (agreeStatusEnum.code.equals(code)) {
                return agreeStatusEnum.msg;
            }
        }
        return "";
    }

    /**
     * 通过多个code 得到描述 （逗号分割）
     *
     * @param codes
     * @return
     */
    public static String getMsgsByCodes(String codes) {
        if (StringUtils.isBlank(codes)) {
            return "";
        }
        String msgs = "";
        for (String code : codes.split(",")) {
            for (MarketerChannelCodeEnum agreeStatusEnum : MarketerChannelCodeEnum.values()) {
                if (agreeStatusEnum.code.equals(code)) {
                    msgs += agreeStatusEnum.msg;
                }
            }
        }

        return msgs;
    }

    /**
     * 通过单个code 得到枚举
     *
     * @param code
     * @return
     */
    public static String getNewCodeByCode(String code) {
        for (MarketerChannelCodeEnum agreeStatusEnum : MarketerChannelCodeEnum.values()) {
            if (agreeStatusEnum.code.equals(code)) {
                return agreeStatusEnum.newCode;
            }
        }
        return code;
    }


    public String getMsg() {
        return msg;
    }

    public String getCode() {
        return code;
    }

    public String getNewCode() {
        return newCode;
    }
}
